package 网易互娱;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main2 {
    public static void main(String[] args) throws IOException {
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        String[] s = bf.readLine().split(" ");
        int N = Integer.parseInt(s[0]);
        int K = Integer.parseInt(s[1]);
        int [][] num = new int[N][2];
        for (int i = 0; i < N; i++) {
            String[] s1 = bf.readLine().split(" ");
            num[i][0] = Integer.parseInt(s1[0]);
            num[i][1] = Integer.parseInt(s1[1]);
        }
        System.out.println(find(num, K));
    }

    public static int find(int[][] num, int K) {
        int res = 0;
        for (int i = 0; i < num.length - 1; i++) {
            for (int j = i+1; j <num.length ; j++) {
                int temp = Math.max(Math.abs(num[i][0]-num[j][0]),Math.abs(num[i][1]-num[j][1]));
                if(temp == K) {
                    res++;
                }
            }
        }
        return res;
    }
}
